home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Inne / Gry / Carnage_Contest / scripts / CC Original / movement / Pogo Stick.lua < prev    next >
Text File  |  2009-09-28  |  2KB  |  70 lines

  1. --------------------------------------------------------------------------------
  2. -- Weapon Pogo Stick
  3. -- Original Carnage Contest Weapon
  4. -- Script by DC, August 2009, www.UnrealSoftware.de
  5. --------------------------------------------------------------------------------
  6.  
  7. -- Setup Tables
  8. if cc==nil then cc={} end
  9. cc.pogostick={}
  10.  
  11. -- Load & Prepare Ressources
  12. cc.pogostick.gfx_wpn=loadgfx("weapons/pogostick.bmp")                        -- Weapon Image
  13. setmidhandle(cc.pogostick.gfx_wpn)
  14. cc.pogostick.sfx_attack=loadsfx("pogostick.ogg")                            -- Attack Sound
  15.  
  16. --------------------------------------------------------------------------------
  17. -- Weapon: Pogo Stick
  18. --------------------------------------------------------------------------------
  19.  
  20. cc.pogostick.id=addweapon("cc.pogostick","Pogo Stick",cc.pogostick.gfx_wpn,1)    -- Add Weapon (1 use)
  21.  
  22.  
  23. function cc.pogostick.draw()                                                -- Draw
  24.     if weapon_mode==1 then
  25.         -- Draw
  26.         setblend(blend_alpha)
  27.         setalpha(1)
  28.         setcolor(255,255,255)
  29.         setscale(-getplayerdirection(0),1)
  30.         setrotation(0)
  31.         drawimage(cc.pogostick.gfx_wpn,getplayerx(0),getplayery(0)+8)
  32.         hudinfo("Hit [Space] again to deactivate the pogo stick!")
  33.     elseif weapon_shots==0 then
  34.         hudinfo("Hit [Space] once to activate the pogo stick!")
  35.     end
  36. end
  37.  
  38. function cc.pogostick.attack(attack)                                        -- Attack
  39.     if weapon_timer>0 then
  40.         weapon_timer=weapon_timer-1
  41.     end
  42.     -- Activate / Deactive
  43.     if (attack==1) and weapon_timer<=0 then
  44.         weapon_timer=10
  45.         if weapon_shots==0 then
  46.             weapon_mode=1
  47.             weapon_shots=1
  48.             useweapon(1)
  49.         else
  50.             weapon_mode=0
  51.         end
  52.     end
  53.     -- Super Jump Power!
  54.     if (weapon_mode==1) then
  55.         -- Pogo Jump
  56.         if getplayeraction(0)==0 then
  57.             playerpush(0,getplayerdirection(0)*1.0,-7.0,1,0)
  58.             playsound(cc.pogostick.sfx_attack)
  59.         end
  60.         -- Avoid Falldamage
  61.         if getplayeryspeed(0)>7.0 then
  62.             playerpush(0,getplayerxspeed(0),7.0,1,0)
  63.         end
  64.         -- Timeout (disable stick)
  65.         if getframesleft()<=1 then
  66.             weapon_mode=2
  67.         end
  68.     end
  69. end
  70.